<?php

namespace YmPhp\Admin\Http\Actions\Business;

use YmPhp\Admin\Tree\RowAction;
use YmPhp\Admin\Models\BusinessCategory;

class CategoryShow extends RowAction
{
    public function handle()
    {
        $key = $this->getKey();

        $category= BusinessCategory::find($key);

        $category->update(['hideindex' => $category->hideindex ? 0 : 1]);

        return $this
            ->response()
            ->success(trans('admin.update_succeeded'))
            ->location('business/business_category');
    }

    public function title()
    {
        $icon = $this->getRow()->hideindex ? 'icon-eye-off' : 'icon-eye';

        return "&nbsp;<i class='feather $icon'></i>&nbsp;";
    }
}
